package cn.xy.system.listener;


import cn.xy.system.service.IPermissionScanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
@Slf4j
public class PermissionScanListener implements ServletContextListener {
    @Autowired
    private IPermissionScanService permissionScanService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //开启异步线程启动，不影响主线程启动
        new Thread(new Runnable() {
            @Override
            public void run() {
                log.info("开启权限扫描");
                permissionScanService.scan();
                log.info("关闭权限扫描");
            }
        }).start();


    }
}
